import { environment } from './../../environments/environment';
import { Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'
environment

@Injectable({
  providedIn: 'root'
})
export class CommonService {

  constructor(public http:HttpClient) { }
  
  
  postApiJson(api:string,paramsJson:any){
    
    const httpOptions:Optional = {
      Headers: new HttpHeaders({
        'Content-type':'application/json'
      })
    }

    console.log(paramsJson);
    return new Promise((resolve:any,reject:any) => {
      this.http.post(environment.doLoginApi+api ,paramsJson,httpOptions)
      .subscribe((response:any) => {
          undefined;
          resolve(response);
      }, error => ((err:any) =>{
          console.log(error);
      }), () => {
        // console.log("请求进行中");
      });
    });

  }

 }
